package edu.washington.ling.syntric.struct.projection;

import java.util.LinkedList;
import java.util.List;

import edu.stanford.nlp.util.StringUtils;

public abstract class ProjectionNode {
	private List<String> rootLabels;
	private String headChildLabel;
	private ProjectionNode parent;
	private ProjectionNode child;
	
	public ProjectionNode(List<String> rootLbls, String headChildLbl) {
		rootLabels = rootLbls;
		headChildLabel = headChildLbl;
		parent = null;
		child = null;
	}
	

	public void setParent(ProjectionNode p) {
		parent = p;
	}
	
	public void setChild(ProjectionNode p) {
		child = p;
	}
	public boolean hasHeadChildLabel() {
		return (headChildLabel != null);
	}
	
	public boolean hasSpine() {
		return (rootLabels != null && headChildLabel != null);
	}
	public boolean hasParent() {
		return (parent != null);
	}
	
	public boolean hasChild() {
		return (child != null);
	}
	public String getRootLabel() {
		return rootLabels.get(0);
	}
	public List<String> getRootLabels() {
		return rootLabels;
	}
	public String getHeadChildLabel() {
		return headChildLabel;
	}
	
	public String getSpine() {
		List<String> spineStrs = new LinkedList<String>();
		for (String rootLabel: rootLabels) {
			spineStrs.add(rootLabel);
		}
		spineStrs.add(headChildLabel);
		return StringUtils.join(spineStrs, " ");
	}
	public ProjectionNode getParent() {
		return parent;
	}
	
	public ProjectionNode getChild() {
		return child;
	}

}
